using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Text.RegularExpressions;

namespace Test1
{
	/// <summary>
	/// Summary description for Formatting.
	/// </summary>
	public class Formatting : System.Windows.Forms.Form
	{
		private System.Windows.Forms.TextBox txtText;
		private System.Windows.Forms.TextBox txtPattern;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Button btnTest;
		private System.Windows.Forms.Button btnExit;
		private System.Windows.Forms.TextBox txtResult;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Formatting()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.txtText = new System.Windows.Forms.TextBox();
			this.txtPattern = new System.Windows.Forms.TextBox();
			this.label1 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.btnTest = new System.Windows.Forms.Button();
			this.btnExit = new System.Windows.Forms.Button();
			this.txtResult = new System.Windows.Forms.TextBox();
			this.SuspendLayout();
			// 
			// txtText
			// 
			this.txtText.Location = new System.Drawing.Point(48, 8);
			this.txtText.Name = "txtText";
			this.txtText.Size = new System.Drawing.Size(168, 20);
			this.txtText.TabIndex = 0;
			this.txtText.Text = "";
			// 
			// txtPattern
			// 
			this.txtPattern.Location = new System.Drawing.Point(48, 32);
			this.txtPattern.Name = "txtPattern";
			this.txtPattern.Size = new System.Drawing.Size(168, 20);
			this.txtPattern.TabIndex = 1;
			this.txtPattern.Text = "";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(0, 8);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(32, 16);
			this.label1.TabIndex = 3;
			this.label1.Text = "Text";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(0, 32);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(48, 16);
			this.label2.TabIndex = 4;
			this.label2.Text = "Pattern";
			// 
			// btnTest
			// 
			this.btnTest.Location = new System.Drawing.Point(224, 8);
			this.btnTest.Name = "btnTest";
			this.btnTest.Size = new System.Drawing.Size(64, 48);
			this.btnTest.TabIndex = 5;
			this.btnTest.Text = "Test";
			this.btnTest.Click += new System.EventHandler(this.btnTest_Click);
			// 
			// btnExit
			// 
			this.btnExit.Location = new System.Drawing.Point(208, 64);
			this.btnExit.Name = "btnExit";
			this.btnExit.Size = new System.Drawing.Size(80, 24);
			this.btnExit.TabIndex = 7;
			this.btnExit.Text = "Close";
			this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
			// 
			// txtResult
			// 
			this.txtResult.Location = new System.Drawing.Point(32, 96);
			this.txtResult.Name = "txtResult";
			this.txtResult.Size = new System.Drawing.Size(168, 20);
			this.txtResult.TabIndex = 8;
			this.txtResult.Text = "";
			// 
			// Formatting
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(292, 273);
			this.Controls.Add(this.txtResult);
			this.Controls.Add(this.btnExit);
			this.Controls.Add(this.btnTest);
			this.Controls.Add(this.txtPattern);
			this.Controls.Add(this.txtText);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label1);
			this.Name = "Formatting";
			this.Text = "Integer formatting test";
			this.ResumeLayout(false);

		}
		#endregion

		private void button1_Click(object sender, System.EventArgs e)
		{
			System.Diagnostics.Process.Start("http://www.regexlib.com/CheatSheet.htm");
		}

		private void btnTest_Click(object sender, System.EventArgs e)
		{
			int i;
			try 
			{
				i = int.Parse(this.txtText.Text);
			}
			catch (Exception) 
			{
				this.txtResult.Text = "error.";
				return;
			}

			this.txtResult.Text = i.ToString(this.txtPattern.Text);
			

		}

	

		private void btnExit_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}


	}
}
